import sys

filename = input("文件名称").strip()
file_mode = input("操作模式").strip()

try:
    fobj = open(filename, mode=file_mode)
except FileNotFoundError as e:
    # e存放python本身的报错
    print(e)
    print("shabi")
    # 出错直接退出；
    sys.exit()
except ValueError as e:
    print(e)
    print("dashabi")
    sys.exit()

data = fobj.read()
print(data)

fobj.close()